import { adList, removeFakeList, addFakeList, updateFakeList } from '@/services/api';

export default {
  namespace: 'list',

  state: {
    list: [],
  },

  effects: {
    *fetch({ payload }, { call, put }) {
      const response = yield call(adList, payload);
      yield put({
        type: 'updateList',
        payload: Array.isArray(response) ? response : response.data || [],
      });
    }
  },

  reducers: {
    updateList(state, action) {
      console.log('action', action)
      return {
        ...state,
        list: action.payload
      };
    }
  },
};
